//
//  SEChatConfirmEndCell.swift
//  SmartEyeForPatient
//
//  Created by QDSG on 2021/5/9.
//

import UIKit

class SEChatConfirmEndCell: UITableViewCell {
    
    weak var delegate: SEChatCellDelegate?
    
    func update(with viewModel: SEChatViewModel) {
        let status = SEInquiryChangeStatus(rawValue: viewModel.chatRecord.content ?? "0") ?? .waitPay
        statusLabel.isHidden = status.statusTextHidden
        confirmButton.isHidden = !status.statusTextHidden
        rejectButton.isHidden = !status.statusTextHidden
        
        statusLabel.text = status.statusText
        statusLabel.textColor = status.statusTextColor
    }
    
    @IBOutlet private weak var containerView: UIView! {
        didSet {
            containerView.setLayerCorners(rect: containerView.bounds, radius: 6)
            containerView.setShadow()
        }
    }
    
    @IBOutlet private weak var statusLabel: UILabel!

    @IBOutlet private weak var confirmButton: UIButton! {
        didSet {
            confirmButton.layer.cornerRadius = confirmButton.height / 2
        }
    }
    
    @IBOutlet private weak var rejectButton: UIButton! {
        didSet {
            rejectButton.layer.cornerRadius = rejectButton.height / 2
            rejectButton.layer.borderWidth = 1
            rejectButton.layer.borderColor = Asset.main.color.cgColor
        }
    }
    
    @IBAction private func confirmEndAction() {
        delegate?.confirmEndCell(self, confirmEndInquiry: true)
    }
    
    @IBAction private func rejectEndAction() {
        delegate?.confirmEndCell(self, confirmEndInquiry: false)
    }
    
}
